import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;


public class Main {

	static final int N = 5;
	private static final String INPUT_FILE = "input.txt";
	private static final String OUTPUT_FILE = "output.txt";
	/**
	 * @param args
	 */
	public static void main(String[] args) {

		try
		{
			MiniMaxAlg alg = extractAlg();
			char winner = alg.RunAlg();
			BufferedWriter fileWriter = new BufferedWriter(new FileWriter(OUTPUT_FILE));
			fileWriter.write(winner);
			fileWriter.close();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	}
	

	public static MiniMaxAlg extractAlg() throws Exception{
		
		BufferedReader fileReader = new BufferedReader(new FileReader(INPUT_FILE));
		char[][] board = new char[N][N];
		
		// Read the board into a matrix
		for(int i = 0; i < N; i++)
		{
			String currLine = fileReader.readLine();

			for(int j = 0; j < N; j++)
			{
				board[i][j] = currLine.charAt(j);
			}
				
		}
		fileReader.close();
		return new MiniMaxAlg(new Board(board, N));
	}


}
